﻿using System;

using agsXMPP;
using agsXMPP.protocol.Base;
using agsXMPP.protocol.client;

using SBPweb.Communication.Shared.Library.Commands;

namespace SBPweb.Communication.Client.Library.Xmpp.Commands
{

    partial class CommandManager : CommandManagerBase
    {

        #region Methods

        protected override void OnInitialize()
        {
        }

        protected override void OnTerminate()
        {
        }

        public override void SendCommand(CommandBase command)
        {
            IQ iq = command.GetRequest() as IQ;
            if (iq == null)
            {
                //throw ex
            }
            connections.client.IqGrabber.SendIq(iq, new IqCB(OnClientIq), command);
        }

        private void OnClientIq(object sender, IQ iq, object state)
        {
            CommandBase cb = (CommandBase)state;
            cb.PutResponse(iq);
            OnCommandReceived(sender, cb);
        }

        #endregion

    }

}